package br.com.infocruz.seam.crm.ejb.session;

import br.com.infocruz.seam.crm.ejb.model.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("addressList")
public class AddressList extends EntityQuery<Address> {

	private static final String EJBQL = "select address from Address address";

	private static final String[] RESTRICTIONS = { "lower(address.city) like lower(concat(#{addressList.address.city},'%'))",
			"lower(address.country) like lower(concat(#{addressList.address.country},'%'))", "lower(address.state) like lower(concat(#{addressList.address.state},'%'))",
			"lower(address.street) like lower(concat(#{addressList.address.street},'%'))", "lower(address.zipcode) like lower(concat(#{addressList.address.zipcode},'%'))", };

	private Address address = new Address();

	public AddressList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Address getAddress() {
		return address;
	}
}
